🌎 rns.kin.earth git 🌍
Commit 2ef58d8b59e32854f936b795e624ddba3a74a144
Parents : 15f2d16
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Date : 2026-05-17T22:01:30+02:00
Better table cell truncation method
Changes
Diff
diff --git a/RNS/Utilities/rngit/util.py b/RNS/Utilities/rngit/util.py
index 04f9330d..435bd888 100644
--- a/RNS/Utilities/rngit/util.py
+++ b/RNS/Utilities/rngit/util.py
@@ -689,16 +689,18 @@ class MarkdownToMicron:
def _truncate_cell(self, text, width):
if self._visible_width(text) <= width: return text
-
- stripped = text
- stripped = re.sub(r'`[FB][0-9a-fA-F]{3}', '', stripped)
- stripped = re.sub(r'`[!*_]', '', stripped)
- stripped = re.sub(r'`f`b', '', stripped)
-
- if len(stripped) <= width - 1: return text
-
- truncated = stripped[:width - 1] + "…"
- return truncated
+
+ truncation_point = len(text)
+ while truncation_point > 0 and self._visible_width(text[0:truncation_point]) >= width:
+ truncation_point -= 1
+
+ truncated = text[:truncation_point]
+
+ # TODO: Track opened tags and close any that
+ # were not closed yet.
+
+ RNS.log(f"Truncated: {truncated}")
+ return truncated + "…"
def _wrap_text(self, text, width):
if not text: return [""]
Served by rngit 1.5.0 - Generated in 0.04s